dojo.provide('app.form.ResultsPane');
dojo.require('dijit.layout.ContentPane');
dojo.declare('app.form.ResultsPane', [ dijit.layout.ContentPane ], {
	items : [],
	constructor : function() {
		this.inherited(arguments);
	},
	_setItemsAttr : function(items) {
		if (items) {
			this.destroyDescendants();
			this._render(items);
		} else {
			this._emptyList();
		}
	},
	_setHrefAttr : function(href) {
		// do nothing;
	},
	onBegin : function(size, req) {
		this.destroyDescendants();
		this._loading();
	},
	onComplete : function(items, req) {
		if (items && items.length > 0) {
			this._render(items);
		} else {
			this._emptyList();
		}
	},
	onError : function(err, req) {
	},
	createItem : function(item, containerNode) {
		// implement
	},
	_render : function(items) {
		this.items = items;
		var _self = this;
		dojo.forEach(items,
				function(item, idx, arr) {
					_self.createItem(item, dojo.create('div', {},
							_self.containerNode));
				});
	},
	_loading : function() {

	},
	_emptyList : function() {

	},
	fetch : function(args) {
		var _self = this;
		args.onBegin = function(size, req) {
			_self.onBegin(size, req);
		};
		args.onComplete = function(items, req) {
			_self.onComplete(items, req);
		};
		args.onError = function(err, req) {
			_self.onError(err, req);
		};
		return this.store.fetch(args);
	}
})